package com.gzck.gzck_verson2.controller;

import com.gzck.gzck_verson2.pojo.GAgreementType;
import com.gzck.gzck_verson2.service.IGAgreementTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/g-agreement-type")
public class GAgreementTypeController {

    @Autowired
    private IGAgreementTypeService agreementTypeService;

    // 添加协议类型
    @PostMapping("/add")
    public boolean addAgreementType(@RequestBody GAgreementType agreementType) {
        return agreementTypeService.save(agreementType);
    }

    // 删除协议类型
    @DeleteMapping("/delete/{id}")
    public boolean deleteAgreementType(@PathVariable Long id) {
        return agreementTypeService.removeById(id);
    }

    // 更新协议类型信息
    @PutMapping("/update")
    public boolean updateAgreementType(@RequestBody GAgreementType agreementType) {
        return agreementTypeService.updateById(agreementType);
    }

    // 查询单个协议类型信息
    @GetMapping("/{id}")
    public GAgreementType getAgreementType(@PathVariable Long id) {
        return agreementTypeService.getById(id);
    }

    // 查询所有协议类型信息
    @GetMapping("/all")
    public List<GAgreementType> getAllAgreementTypes() {
        return agreementTypeService.list();
    }
}
